package com.chasmcity.munrobagging.model;

import java.io.Serializable;

/**
 * TODO: Missing class description for LatLongBoundingBox!
 * <p>
 * &copy; Copyright 2010 Kizoom Ltd.
 * <p>
 * $Id: LatLongBoundingBox.java,v 1.4 2011/01/25 17:44:38 kennym Exp $
 */
public class LatLongBoundingBox implements Serializable {

	private final LatLong swCorner;
	private final LatLong neCorner;
	
	public LatLongBoundingBox(LatLong swCorner, LatLong neCorner) {
		this.swCorner = swCorner;
		this.neCorner = neCorner;
	}
	
	public LatLong getNeCorner() {
		return neCorner;
	}
	
	public LatLong getSeCorner() {
		return new LatLong(swCorner.getLatitude(), neCorner.getLongitude());
	}
	
	public LatLong getSwCorner() {
		return swCorner;
	}
	
	public LatLong getNwCorner() {
		return new LatLong(neCorner.getLatitude(), swCorner.getLongitude());
	}
	
	public boolean encloses(LatLong location) {
		return 
		swCorner.getLatitude() <= location.getLatitude() &&
		swCorner.getLongitude() <= location.getLongitude() &&
		neCorner.getLatitude() >= location.getLatitude() &&
		neCorner.getLongitude() >= location.getLongitude();
	}
	
	@Override
	public String toString() {
		return String.format("swCorner=%s, neCorner=%s", swCorner, neCorner);
	}
}
